<?php
    $upfile = $_FILES['myfile'];
    $path = "./uploads";
    
    if($upfile['error'] > 0) {
        switch($upfile['error']) {
            case 1:
                echo "";
            break;
            case 2:
                echo "";
            break;
            case 3:
                echo "";
            break;
            case 4:
                echo "";
            break;
            case 6:
                echo "";
            break;
            case 7:
                echo "";
            break;
            default:
                echo "";
        }
        exit;
    }
    
    $filesize = 0;
    if($filesize > 0 && $filesize < $upfile['size']) {
        die ("死掉了...");
    }
    
    $filetype = $upfile['type'];
    $arr = array("image/png","image/jpeg");
    if(!in_array($filetype,$arr)) {
        die ("格式不正确");
    }
    
    $houzhui = pathinfo($upfile['name'],PATHINFO_EXTENSION);
    do{
        $filename = md5(date("YmdHis").rand(0,999)).".".$houzhui;
    }while(file_exists($filename));
    
    if(move_uploaded_file($upfile['tmp_name'],"./uploads/{$filename}")) {
        echo "文件上传成功";
    }